from PIL import Image
import imp
from isEndModel import predict as isEndPred
from alexnet import predict as pred
import time
from Jump import Jump
import os

#自动跳
def jump():
    jump = Jump()
    while 1:
        time.sleep(1)
        jump.pull_screenshot()
        img = Image.open("./1.png")
        #判断是否游戏结束
        isEnd  = isEndPred(img)
        if isEnd:            
            print('isEnd')
            #重新开始
            os.system('adb shell input tap 650 1700')
        else:
            result = pred(img)
            print(result[0][0])
            jump.jump(jump.calc(result[0][0]))

if __name__ == "__main__":
    jump()